package com.boboPlanet.user.mq.peoducerBean;

import com.boboPlanet.user.mq.PlanetMiddleMqEnum;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO 网关登录过期 mq 配置
 * @Author: mis_wu
 * @Date: 2023/5/16
 * @Company planet
 **/
@Configuration
public class GatewayLoginExpireMqCfg {

    @Bean
    public Queue userMiddleQueue(){
        return new Queue(PlanetMiddleMqEnum.CHANGE_USER_STATE_MQ.getQueue(),true);
    }

    @Bean
    TopicExchange userMiddleExchange() {
        return new TopicExchange(PlanetMiddleMqEnum.CHANGE_USER_STATE_MQ.getExchange(),true,false);
    }

    /**
     * todo:路由绑定交换机(routing-key)
     * @return Binding
     */
    @Bean
    Binding userMiddleRoutingKey() {
        return BindingBuilder.bind(this.userMiddleQueue()).to(this.userMiddleExchange())
                .with(PlanetMiddleMqEnum.CHANGE_USER_STATE_MQ.getRoutingKey());
    }

}
